package com.warm.pump.frame.gen.util;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by guozj on 2017/2/9.
 */
public class OutJson extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public OutJson() {
        put("code", 0);
    }

    public static OutJson error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static OutJson error(String msg) {
        return error(500, msg);
    }

    public static OutJson error(int code, String msg) {
        OutJson outJson = new OutJson();
        outJson.put("code", code);
        outJson.put("msg", msg);
        return outJson;
    }

    public static OutJson ok(String msg) {
        OutJson outJson = new OutJson();
        outJson.put("msg", msg);
        return outJson;
    }

    public static OutJson ok(Map<String, Object> map) {
        OutJson outJson = new OutJson();
        outJson.putAll(map);
        return outJson;
    }

    public static OutJson ok() {
        return new OutJson();
    }

    public OutJson put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public OutJson setResData(Object value) {
        super.put("resData", value);
        return this;
    }
}
